Skip to content

Fix libxml failure - #39

Merged
ronaldtse merged 2 commits into
mainfrom
fix-libxml-failure-on-windows
Aug 23, 2026
Merged

Fix libxml failure#39
ronaldtse merged 2 commits into
mainfrom
fix-libxml-failure-on-windows

Conversation

@kwkwan

@kwkwan kwkwan commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@kwkwan kwkwan linked an issue Nov 18, 2025 that may be closed by this pull request
@kwkwan
kwkwan force-pushed the fix-libxml-failure-on-windows branch 25 times, most recently from b093d3b to 199f0fd Compare November 19, 2025 05:51
@ronaldtse
ronaldtse requested a review from Copilot November 24, 2025 04:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix libxml failures on Windows by bundling a zlib1.dll binary and adding platform-specific dependency handling. The changes include adding a binary DLL file, a debug script, CI workflow modifications, and Gemfile updates for Windows-specific libxml-ruby version pinning.

Key Changes

  • Added zlib1.dll binary to dlls/ directory for Windows libxml support
  • Created debug.rb script to diagnose and patch PATH for DLL loading
  • Pinned libxml-ruby to version 5.0.4 specifically for Windows platform
  • Added rubocop-related gems and CI debug step

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 4 comments.

File Description
dlls/zlib1.dll Binary DLL file added to provide zlib support for Windows
debug.rb Debug script to locate gems and modify PATH for DLL discovery
Gemfile Platform-specific libxml-ruby versioning and additional rubocop gems
.github/workflows/rake.yml Added CI step to run debug script after Ruby setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread debug.rb Outdated
Comment on lines +8 to +38
# all_files = Dir.glob("#{spec.full_gem_path}/**/*").select { |f| File.file?(f) }

# all_files.each do |file|
# puts file
# end

# check PATH
puts ENV.fetch("PATH", nil)

# patch lib/libxml-ruby.rb
# filepath = "a.txt"
filepath = File.expand_path("#{spec.full_gem_path}/dlls")
ENV["PATH"] = "#{ENV.fetch("PATH", nil)};#{filepath}"

puts "Patched PATH:"
puts ENV.fetch("PATH", nil)

# original_content = File.read(filepath)

# line_to_add = "ENV['PATH'] = ENV['PATH'] + ';' + File.expand_path(File.dirname(__FILE__))\nputs 'Patched PATH: ' + ENV['PATH']"

# # Combine the new line with the original content
# new_content = line_to_add + "\n" + original_content

# # Overwrite the file with the new content
# File.write(filepath, new_content)

# puts "new_content================"
# puts new_content
# puts "==========================="

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This debug script contains extensive commented-out code (lines 8-12, 17-37) that should be removed before merging. Commented code clutters the codebase and can be retrieved from version control history if needed.

Suggested change
# all_files = Dir.glob("#{spec.full_gem_path}/**/*").select { |f| File.file?(f) }
# all_files.each do |file|
# puts file
# end
# check PATH
puts ENV.fetch("PATH", nil)
# patch lib/libxml-ruby.rb
# filepath = "a.txt"
filepath = File.expand_path("#{spec.full_gem_path}/dlls")
ENV["PATH"] = "#{ENV.fetch("PATH", nil)};#{filepath}"
puts "Patched PATH:"
puts ENV.fetch("PATH", nil)
# original_content = File.read(filepath)
# line_to_add = "ENV['PATH'] = ENV['PATH'] + ';' + File.expand_path(File.dirname(__FILE__))\nputs 'Patched PATH: ' + ENV['PATH']"
# # Combine the new line with the original content
# new_content = line_to_add + "\n" + original_content
# # Overwrite the file with the new content
# File.write(filepath, new_content)
# puts "new_content================"
# puts new_content
# puts "==========================="
# check PATH
puts ENV.fetch("PATH", nil)
filepath = File.expand_path("#{spec.full_gem_path}/dlls")
ENV["PATH"] = "#{ENV.fetch("PATH", nil)};#{filepath}"
puts "Patched PATH:"
puts ENV.fetch("PATH", nil)

Copilot uses AI. Check for mistakes.
Comment thread debug.rb Outdated

require "rubygems"
# spec = Gem::Specification.find_by_name("libxml-ruby")
spec = Gem::Specification.find_by_name("moxml")

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded gem name "moxml" appears to be incorrect or test-specific. If this is a debug script intended to remain in the repository, it should use a configurable or correct gem name. If this is only for temporary debugging, it should not be committed.

Suggested change
spec = Gem::Specification.find_by_name("moxml")
gem_name = ENV["GEM_NAME"] || ARGV[0] || "libxml-ruby"
spec = Gem::Specification.find_by_name(gem_name)

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/rake.yml Outdated
echo "---" > .bundle/config 2>&1 || true
echo 'BUNDLE_BUILD__LIBXML___RUBY: "--with-xml2-dir=C:/vcpkg/installed/x64-windows --with-xml2-include=C:/vcpkg/installed/x64-windows/include/libxml2 --with-xml2-lib=C:/vcpkg/installed/x64-windows/lib"' >> .bundle/config 2>&1 || true
after-setup-ruby: |
bundle exec ruby debug.rb 2>&1 || true

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The after-setup-ruby step runs the debug script but always succeeds due to || true. This masks failures and defeats the purpose of running it in CI. Either:

  1. Remove || true to catch failures, or
  2. Remove this debug step entirely if it's not needed for CI validation
Suggested change
bundle exec ruby debug.rb 2>&1 || true
bundle exec ruby debug.rb 2>&1

Copilot uses AI. Check for mistakes.
Comment thread Gemfile Outdated
Comment on lines +28 to +32
if Gem.win_platform?
gem "libxml-ruby", "5.0.4"
else
gem "libxml-ruby"
end

Copilot AI Nov 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The libxml-ruby version is pinned to exactly "5.0.4" on Windows but allows any version on other platforms. This inconsistency could lead to different behavior across platforms. Consider:

  1. Documenting why Windows requires this specific version
  2. Using the same version constraint across platforms if possible
  3. Adding a comment explaining the platform-specific versioning
Suggested change
if Gem.win_platform?
gem "libxml-ruby", "5.0.4"
else
gem "libxml-ruby"
end
# Pinning libxml-ruby to 5.0.4 for all platforms to ensure consistent behavior.
# If a newer version is required, update this constraint after verifying cross-platform compatibility.
gem "libxml-ruby", "5.0.4"

Copilot uses AI. Check for mistakes.
@kwkwan
kwkwan force-pushed the fix-libxml-failure-on-windows branch 21 times, most recently from 0687768 to cfb2b91 Compare February 13, 2026 07:09
Comment thread .github/workflows/windows.yml Fixed
@kwkwan
kwkwan force-pushed the fix-libxml-failure-on-windows branch 5 times, most recently from 051c767 to fe79ac8 Compare February 13, 2026 08:25
Adds a dedicated Windows workflow that installs libxml2, ragel, and
the UCRT64 toolchain from MSYS2, configures libxml-ruby's extension
build against them, prepares the vendored oga/ruby-ll forks, and runs
the adapter spec suite (which includes the libxml adapter contract).

Replaces the exploratory state of this branch: the commented-out
pull_request trigger, debug.rb workflow step, and vcpkg-based
before-setup-ruby on the metanorma/ci generic workflow are all
dropped in favor of this self-contained workflow matching the
structure of rake.yml.
@ronaldtse
ronaldtse force-pushed the fix-libxml-failure-on-windows branch from fe79ac8 to 4d7fb10 Compare August 23, 2026 06:48
stackprof's native extension uses SIGPROF/sigaction, which do not
exist on Windows, so bundle install fails there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libxml fails to run properly on Windows (Ruby 3.1, Ruby 3.4)

5 participants